#include <iostream>
#include <bitset>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
class Solution
{
public:
    int maxProduct(vector<string> &words)
    {
        int res = 0;
        unordered_map<string, uint32_t> u_map;
        // 提前建立字母掩码
        for (auto &e : words)
        {
            for (auto c : e)
            {
                u_map[e] |= 1 << (c - 'a');
            }
        }
        for (int i = 0; i < words.size(); i++)
        {
            for (int j = i + 1; j < words.size(); j++)
            {
                string &a = words[i], &b = words[j];
                // O(1)判断是否不包含相同字母
                if (!(u_map[a] & u_map[b]))
                {
                    int t = a.size() * b.size();
                    res = t > res ? t : res;
                }
            }
        }
        return res;
    }
};